<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                template="./../../templates/template.xhtml">


    <ui:define name="content">

        <p:growl showDetail="true" />

        <h:form prependId="false">
                    <h:messages errorStyle="color: #d20005" infoStyle="color: green"   showDetail="true"/>

            <p:panel header="#{bundle['pessoa.form.title']}">


                    <h:panelGrid columns="2">


                    <h:outputLabel value="Nome :"></h:outputLabel>
                    <p:inputText id="txt_nome" value="#{pessoaCrudMB.entity.nome}"/>
                    

                    <h:outputLabel value="CPF :"></h:outputLabel>

                    <p:inputMask mask="999.999.999-99" value="#{pessoaCrudMB.entity.cpf}"/>


                    <p:commandButton value="#{bundle['button.add']}" action="#{pessoaCrudMB.create}"
                                     update="pessoas,alerta" />
                    

                </h:panelGrid>
            </p:panel>

        </h:form>
        
        <p:spacer width="100%" height="15" />
        
        <h:form prependId="false">
            <p:dataTable id="pessoas" value="#{pessoaCrudMB.entityList}" var="c"
                         rowEditListener="#{pessoaCrudMB.onEditRow}" onRowEditUpdate="alerta"
                         selection="#{pessoaCrudMB.selecteds}" paginator="true" rows="10"
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="5,10,15">

                <f:facet name="header">#{bundle['pessoa.list']}
                </f:facet>

                <p:column selectionMode="multiple" />

                <p:column headerText="Nome">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{c.nome}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{c.nome}" />
                        </f:facet>
                    </p:cellEditor>

                </p:column>


                <p:column headerText="CPF">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{c.cpf}" />
                        </f:facet>

                        <f:facet name="input">
                            <p:inputMask mask="999.999.999-99" value="#{c.cpf}"/>
                        </f:facet>
                    </p:cellEditor>

                </p:column>

                <p:column headerText="Editar" style="width:50px;text-align: center;"> 
                    <p:rowEditor />
                </p:column>

                <f:facet name="footer">
                    <p:commandButton value="#{bundle['button.del']}" image="ui-icon-trash"
                                     update="pessoas,alerta" action="#{pessoaCrudMB.removeSelecteds}" />
                </f:facet>

            </p:dataTable>
        </h:form>

    </ui:define>


</ui:composition>
